package com.naiterui.ehp.bs.patient.controller.inner;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.naiterui.ehp.bp.bo.patient.MedicationRemindBO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bp.utils.beans.BeanUtil;
import com.naiterui.ehp.bs.patient.exception.ExceptionCodes;
import com.naiterui.ehp.bs.patient.service.IMedicationRemindService;
import com.naiterui.ehp.bs.patient.vo.MedicationRemindVO;

import io.swagger.annotations.Api;

/**
 * 用药提醒
 *
 * @author fanjd
 * @since 1.0.0
 */
@Api(tags = {SwaggerTag.INNER_API + SwaggerTag.MEDICINE_REMIND})
@RequestMapping("ap/inner/medication/remind")
@Controller
public class ApInnerMedicationRemindController {
    @Autowired
    private IMedicationRemindService medicationRemindService;

    /**
     * 患者用药提醒查询
     *
     * @param patientId
     *
     * @return
     *
     * @throws BusinessException
     * @Author fanjd
     * @Date 2018年1月2日
     * @since 1.0.0
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseVO<MedicationRemindBO> detail(Long patientId) throws BusinessException {
        MedicationRemindVO medicationRemindVO = this.medicationRemindService.detail(patientId);
        MedicationRemindBO medicationRemindBO = new MedicationRemindBO();
        BeanUtil.copyProperties(medicationRemindVO, medicationRemindBO);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS, medicationRemindBO);
    }

    /**
     * 系统新增一个用药提醒
     *
     * @param patientId     患者id
     * @param remindTimes   提醒次数
     * @param remindContent 提醒内容
     * @param remindDays    提醒天数
     *
     * @return
     *
     * @throws BusinessException
     * @Author fanjd
     * @Date 2018年1月5日
     * @since 1.0.0
     */
    @RequestMapping("/update")
    @ResponseBody
    public ResponseVO<Void> update(Long patientId, Integer remindTimes, String remindContent, Integer remindDays) throws BusinessException {
        this.medicationRemindService.update(patientId, remindTimes, remindDays, remindContent, 1);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }
}
